package gae.google.tcserver.db;

import java.io.Serializable;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

/**
 * The <tt>User</tt> class defines the database table that
 * holds information about this entity 
 *
 * @author Lars Friberg
 *
 * @date 2011-01-15
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class User implements Serializable {

	/**
	 * Serial version Id
	 */
	private static final long serialVersionUID = 9055922545680540209L;
	
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	private Key userKeyId;				 // this is the primary key for every user
	
	@Persistent
	private String userName;			 // this is the user name
	
	@Persistent
	private String userPassword;		 // this is the user password

	@Persistent
	private String socialSecurityNumber; // this is the social security number

	@Persistent
	private Boolean userAdministrator; 	 // this is the user administrator flag

	@Persistent
	private List<Key> teamKeyIds;	 	 // this is the team id's
	
	/**
	 * get user key Id
	 * 
	 * @return userKeyId the user key id
	 */
	public Key getUserKeyId() {
		return userKeyId;
	}

	/**
	 * get user name
	 * 
	 * @return userName the user name
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * get user password
	 * 
	 * @return userPassword the user password
	 */
	public String getUserPassword() {
		return userPassword;
	}

	/**
	 * get the social security number
	 * 
	 * @return socialSecurityNumber the social security number
	 */
	public String getSocialSecurityNumber() {
		return socialSecurityNumber;
	}

	/**
	 * get the administrator flag (true/false)
	 * 
	 * @return userAdministrator the user administrator flag
	 */
	public Boolean getUserAdministrator() {
		return userAdministrator;
	}

	/**
	 * get team key Id's
	 * 
	 * @return teamKeyIds the team key Id's 
	 */
	public List<Key> getTeamKeyIds() {
		return teamKeyIds;
	}
	
	/**
	 * set team key Id's
	 *
	 * @param teamKeyIds the list of team key Id's to set
	 */
	public void setTeamKeyIds(List<Key> teamKeyIds) {
		this.teamKeyIds = teamKeyIds;
	}
	
	/**
	 * Constructor
	 */
	public User() {
		super();
	}

	/**
	 * constructor, initiate parameters
	 * 
	 * @param userName the user name
	 * @param userPassword the user password
	 * @param socialSecurityNumber the social security number
	 * @param userAdministrator the user administrator flag
	 */
	public User(String userName, String userPassword, String socialSecurityNumber,
			    Boolean userAdministrator) {
		super();
		this.userName = userName;
		this.userPassword = userPassword;
		this.socialSecurityNumber = socialSecurityNumber;
		this.userAdministrator = userAdministrator;
	}
}